<template>
	<view class="page-total">
		<view class="tab-list">
			<view class="list" v-for="(item,index) in TabBarList" 
			@click="onTabBar(item,index)"
			:key="index">
				<!-- <image style="width: 24px;" :src="item.acImg" mode="widthFix" v-show="tabBarShow === index"></image>
				<image style="width: 24px;" :src="item.img" mode="widthFix" v-show="tabBarShow != index"></image> -->
				<text :style="{'color': tabBarShow === index ? '#ff6a84' : '#333333'}" :class="item.icon"></text>
				<text class="tab-li-name" :class="{'action':tabBarShow===index}">{{item.name}}</text>
				<view v-if="index==2" class="num-badge">
					<u-badge :type="type" max="99" :value="value"></u-badge>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type:"error",
				value: 1,
				TabBarList:[
					{
						index: 0,
						name: '首页',
						icon: 'iconfont icon-shouye',
					},
					{
						index: 1,
						name: '分类',
						icon: 'iconfont icon-fenlei',
					},
					{
						index: 2,
						name: '购物车',
						icon: 'iconfont icon-gouwuche',
					},
					{
						index: 3,
						name: '我的',
						icon: 'iconfont icon-wode',
					},
				],
				codeheight: 0,
				isOverall: 0,
				phoneModel: '',
			};
		},
		props:{
			tabBarShow: {
				type: Number,
				default: 0,
			}
		},
		mounted() {
			try {
			    const res = uni.getSystemInfoSync();
					let that = this;
			    // 获取系统信息
			    uni.getSystemInfo({
			    	success(res) {
			    		console.log(res.brand) //手机牌子
			    		console.log(res.model) //手机型号
			    		console.log(res.screenWidth) //屏幕宽度
			    		console.log(res.screenHeight) //屏幕高度
							that.codeheight = Math.round(res.screenHeight);
							that.phoneModel =res.model
							if(res.model.search('iPhone')){
								that.isOverall = 0;
							}else if(Math.round(res.screenHeight)>740){
							 that.isOverall = 1;
							}
							// console.log(that.isOverall);
			    	}
			    });
			} catch (e) {
			    // error
			}
		},
		methods:{
			/**
			 * @param {Object} item
			 * @param {Number} index
			 */
			onTabBar(item,index){
				switch (index){
					case 0:
						wx.switchTab({
							url:'/pages/index/index'
						})
						break;
					case 1:
						wx.switchTab({
							url:'/pages/classify/classify'
						})
						break;
					case 2:
						wx.switchTab({
							url:'/pages/cart/cart'
						})
						break;
					case 3:
						wx.switchTab({
							url:'/pages/my/my'
						})
						break;
				}
			},
			
		}
	}
</script>

<style scoped lang="scss">
	@import 'TabBar.scss';
</style>
